Earlier this year, Tom Gayner, chief investment officer of Markel (MKL -1.17%), visited The Motley Fool. Markel is one of the most respected and well-run insurance companies in the country. It regularly writes insurance policies at a profit, it invests its float wisely, it has a strong culture and capable managers, and it's delivered outstanding long-term returns to its investors. Anyhow, we asked Gayner what other insurance companies he respected. If anyone knows the industry, it is Gayner. His unequivocal answer: RLI (RLI 1.34%), a small property and casualty insurer (around $2 billion in market cap) based in Peoria, Ill.

Company expertise: disciplined underwriting
RLI provides a wide range of property and casualty insurance coverage -- from environmental liability on underground storage tanks to personal liability protection for corporate directors to worker's compensation to surety coverage. It has a staff of experienced underwriters who understand these various niche markets, and those underwriters have free rein to price and sell policies with minimal interference from corporate. And those underwriters are compensated primarily based on the profitability of their policies (not the volume of policies they write). This combination of incentives, expertise, and delegated authority has resulted in an awesome record of underwriting. Its combined ratio, a key measure of insurance profitability for the past six years (2007 to 2012) has been 71, 84, 82, 80, 80, and 89 -- an average of 81. If you want to look back futher, you'll see that the company has underwritten profitbably for 17 consecutive years. If you know anything about insurance, you'll immediately recognize that's terrific. It's a better record underwriting record than both Markel and Berkshire Hathaway (BRK.B -0.68%), which happen to be two of the most respected companies in the insurance industry.    

Maui Jim's: a hidden asset
Obviously, specialty insurance is the company's focus today. But it started out as a contact lens insurance company (it used to be known as Replacement Lens Insurance before changing its name to RLI). And, as a result of that legacy, the company owns a 40% stake in Maui Jim's, a premier brand in luxury sunglasses. In 2012, RLI's share of Maui Jim's profits was $9 million. Obviously, it's a valuable stake, but if you look at RLI's balance sheet, you'll see that the 40% stake is carried at only $56 million. Obviously, that carrying value is very low. It's more a reflection of accounting rules than economic value. The true value of that stake in Maui Jim's is probably three to  four times the value reflected on the balance sheet. 

Shareholder returns: an admirable record
Over the past 10- and 15-year periods, RLI has generated average compounded shareholder returns of 14% per year, on average doubling the return of the S&P 500. Over the past one-, three-, and five-year periods, the company has delivered annual returns of 59%, 29%, and 18%. In other words, this stock has a clear, long-term record of beating the market. Obviously, its management and underwriting discipline are key drivers of that. Also, the company has an ownership culture (insiders own 11% of the stock), which aligns employees with stockholders. And capital allocation has been very shareholder-friendly. If the company has excess capital, it returns it to shareholders. It has a regular dividend, which it has increased for 37 consecutive years. But, beyond that, the company has been very aggressive recently in paying out special dividends. It paid special dividends of more than $5 per share in 2011 and 2012, and recently the company announced another special dividend of $3.34 for shareholders of record as of Nov. 26. Say you had bought shares at the beginning of 2010 (priced around $54 per share): You'd have received around $25 in regular and special dividends, and your shares would be worth nearly double (up 95% to $104 per share). That's a 139% return in less than four years -- not bad for a boring little insurance company that no one, besides Tom Gayner, has ever heard of. 

Foolish bottom line
Obviously, there's a lot to like about RLI as a business. Its underwriting record is excellent, it has a hidden asset in Maui Jim's, and it's been a huge winner for shareholders. It also has a strong management team with conservative reserving policies. But, even as a small company, RLI's performance hasn't gone totally unnoticed. At least based on price-to-book value, it's gotten a bit expensive. Today, it trades at 2.6 times book value, which is pretty expensive even if you think book value is understated, as I do. And, with Markel trading at less than 1.2 times book value and Berkshire Hathaway at 1.4, RLI isn't a no-brainer buy. But it is a great company, and it's likely to get cheaper at some point in the future. I'd advise keeping an eye on it -- if the valuation becomes more attractive, then that's the time to pounce.