It doesn't really tell the browser not to cache it -- The browser caches each query string individually, so if the next request is to rails.js?9283482934, that is a new URL that needs to be requested from the server.
That lets you tell the browser to cache the file, but by updating the html file with a new number, you can force all client browsers to download the new version without actually changing the new of the js file.
The reason to use the number is to allow clients to cache it but also allow you to force an update -- so it should not negatively affect the performance. However, if you are programmatically generating a random number for each request, you will be forcing all clients to always request the file, effectively disabling caching for that file.