Several routes, all legitimate. The most common are building and selling objects or clothing, designing for other residents, hosting events, teaching a skill, or taking an in-world job — scripting and texture work are in steady demand.
Earnings arrive as Linden Dollars, the in-world currency, which can be converted to real money through the official exchange. Whatever you do, avoid the "get rich quick" schemes advertised in-world; Second Life has always attracted more scams than opportunities, and they're easy to spot once you know the pattern.