Whenever you defeat a boss at the end of a world, you will get 10 rally tickets. Note that this can happen once with each boss. Defeating a boss again won't give you rally tickets.
When you build the bonus house in your Kingdom you will have the chance to win a rally ticket during the bonus game you will be able to play. The game can be played once every 24 hours.
Purchasing the game gives you an additional 20 rally tickets.
When you collect all the pink coins on a given level you will get a random reward after completing the level. This reward can be some rally tickets.
When you build the mega ? block you can get free rally ticket by clicking on it. Note that you can't do this very often. You can get many rally tickets from the mega ? block.
The long ? block can bring you lots of rally tickets. You can get 20 rally tickets by clicking on the long ? block.
Once you link your Nintentdo account to the game, you will get some rally tickets. See also how to unlock all characters.
Once you collect all 5 pink coins on a given level, you will be able to compete for the purple coins then the black coins. Collecting all 5 coins will usually reward you with some rally tickets.
Once you link your Nintendo account to the game, you will be able to exchange your Nintendo points for rally tickets. See also why Super Mario Run is a good game.