A patent gives the owner of the patent the exclusive right to use the invention. Anyone else who wants to use the invention has to get permission from the owner of the patent. In many cases, the owner of the patent will then charge for the right to use the invention in the patent. This is merely a right to use the invention idea. The owner of the patent doesn't need to actually build the machines or software and lease it to people. He or she can let them make the capital investments and just charge them for the right to use the invention idea. It's a neat way to make money, and there are many inventors who do this for a living. Of course, there is nothing stopping you from actually going into business and building your invention for use!
Like a title to a real-estate property, a patent is a title to a piece of intellectual property. You can sell you patent to other people if you wish, the same way you can sell your house to someone else. In this case, the inventor listed on the patent document will still be you, but the assignee of the patent will be a company that you have sold it to. Inventors working in companies are often obligated to assign all rights to their inventions to their companies. For these inventors, the glory is theirs, but the money isn't.
You should be aware though, that patents do not last forever. Depening on the country you are in, patents may have different lifespans (usually 15-25 years). This is done intentionally as part of the socio-economic objective behind the patent system. Simply put, patents are meant to encourage people to put in time and effort to invent new things for the benefit of mankind. To do this, inventors (or whoever they sold the patent to) are given the exclusive right to use the invention for some period of time. In exchange, the details of your invention are published to the whole world for to increase the world's body of knowledge. And after the patent expires, anyone has the right to use the invention, thus benefitting humanity.
One clear example of this which you may have heard of is in the manufacture of generic drugs. Pharmaceutical companies invest large sums of money designing drugs to treat diseases, and are compensated by being given the exclusive right to sell their medicines for a certain period of time. Once their patents expire, any drug company is free to manufacture the exact same medicine. This system steadily improves the medicines available to mankind over time, while keeping incentives for companies to invest the large sums of money needed to research and develop new medicines.
You should also be aware that patents can only be enforced in countries in which they have been filed. So in many cases, important inventions are filed in all countries where an inventor thinks there might be people wanting to use the invention. The courts in different countries may also enforce patent protections differently. This means that you may not be able to profit from your invention in certain countries even if you are able to do so in the United States.