Improving the data rate of machine-type communication (MTC) is essential in supporting emerging Internet of things (IoT) applications ranging from real-time surveillance to edge machine learning. To this end, in this paper we propose a resource allocation approach for uplink transmissions within a random access procedure in MTC by exploiting multichannel selection diversity, coined explore-before-talk (EBT). Each user in EBT first sends pilot signals through multiple channels that are initially allocated by a base station (BS) for exploration, and then the BS informs a subset of initially allocated channels that are associated with high signal-tonoise ratios (SNRs) for data packet transmission by the user while releasing the rest of the channels for other users. Consequently, EBT exploits a multichannel selection diversity gain during data packet transmission, at the cost of exploration during pilot transmission. We optimize this exploration-exploitation trade-off, by deriving closed-form mean data rate and resource outage probability expressions. Numerical results corroborate that EBT achieves a higher mean data rate while satisfying the same outage constraint, compared to a conventional MTC protocol without exploration.