"The first Aleck was Aleck Hoag, a confidence man in New York City who appears to have operated in the 1840s. Aleck was a pimp, and he used the activities of his women to reap additional income through a scheme called the “panel game.” Aleck would wait until the customer was asleep or otherwise occupied, and then he would sneak into the room to steal the customer's wallet and valuables. Patrons got wise to this scheme, and they started blocking doors with chairs and tables. In response, Hoag built false wall panels which slid aside so that he could enter the room without entering the door.
This particular smart aleck qualifies as a wise guy for several reasons. He clearly evaded capture for long enough to develop quite an elaborate system for relieving people of their money and valuables. He also openly boasted about the panel scheme, demonstrating it for curious visitors. Furthermore, Hoag also attempted to avoid paying the police their cut, and “smart aleck” may have actually originated in the constabulary. It didn't take long for Hoag to become well known, and “smart aleck” was a common term in 1860s slang.
As a general rule, “smart aleck” is not a complimentary term. A smart aleck tends to be bold and rather cocky about it, and these traits tend to be frowned upon by many societies. The term may be used pejoratively, in the hopes of encouraging someone to reform, or it may be used in reference to someone who is essentially incorrigible, as a warning to people who might deal with that person."
And here's another link explaining about "Alec" ... http://www.todayifoundout.com/index.php/2010/07/origin-of-the-term-smart-alec/