It did work, but you're only echoing the first element of the array. Use this instead:
echo "${args[@]}"
Bash's syntax for arrays is confusing. Use ${args[@]} to get all the elements of the array. Using ${args} is equivalent to ${args[0]}, which gets the first element (at index 0).
See ShellCheck: Expanding an array without an index only gives the first element.
Also btw you can simplify let i=i+1 to ((i++)), but it's even simpler to use a C-style for loop. And also you don't need to define args before adding to it.
So:
#!/bin/bash
for ((i=0; i<5; ++i)); do
args+=($i)
echo "${args[@]}"
done
echo "${args}"only shows the first element. You need to change it toecho "${args[@]}"to output all elementsi=0 ... while [ $i -lt 5 ]; do ... let i=i+1 ... donecan be replaced withfor ((i=0; i<5; ++i)); do ... done