You can do this at any point in the game by accessing your phone, launching the Internet, selecting Money and Services and buying stock. You can sell the stock at any point in the game when it has gone up in value from the time you purchased.
However, my favorite time to do this is during a mission called "The Hotel Assassination" (one of Lester's missions for Franklin). During the mission, Lester will inform you that Franklin's actions during the mission will boost the price of Betta Pharmaceuticals, so using this method is fast, reliable and doesn't require you to strategically play the market. This is about the 20th mission you will undertake in the game.
Go ahead and start the mission to trigger the opening cutscene. As soon as the cutscene has ended, go into your phone and launch the Internet. Click on "Money and Services" and select the BAWSAQ stock exchange. Locate Betta Pharmaceuticals. Since the stock is guaranteed to rise, I recommend maxing out your funds and buying as much stock as you can (maybe leave a little on the side so you can buy a sniper rifle during the mission). As soon as the mission ends, enter your phone, access "Money and Services" and "My Portfolio". Sell your stock for a great profit and this achievement will unlock!
Here is a video walkthrough (courtesy of GTA Series Videos) of this mission, should you need any assistance completing it. Keep in mind the walkthrough does not show the stock purchase. I am also including a video on how to generally buy and sell stocks in the game (courtesy of MrBossFTW).