The goal here is launch Mario from a cannon so he hits Luigi. The coins are just there for decoration but why not grab a few in you can? The important thing here is that you can't knock Luigi off the stage or else you lose. So if you bump into an object that bumps into Luigi and he falls off the stage, you lose. This is not usually a problem.