How did the Republicans beat the Whigs?
They didn't. The Whigs' last Presidential candidate, Winfield Scott, lost by over 200 electoral votes in 1852. By the next Presidential election, 1856, when the Republicans ran their first Presidential candidate, the Whigs had already disbanded.
In between was the 1854-55 Congressional elections, the first federal election with Republican candidates, but the Republicans came in a distant 3rd behind the Democrats and Whigs in the Senate and 4th behind the Democrats, Whigs, and Know-Nothings in the House. No party held a majority of the House--the election of Speaker took about 2 months and resulted in the election of Know Nothing, Free Soiler, and future infamous Union general Nathaniel Banks as Speaker.
So the Republican Party never really "beat" the Whigs. It lost to the Whigs in the only federal election contested by both parties.
The Republican Party essentially was built from the wreckage of the Whigs. Similar platforms. Lincoln had been a Whig.