TOP 1
instructs SQL Server that you only want to return one record, so your query is doing exactly what you've asked it to do.
Based on your description, you want something like:
WITH cte As
(
SELECT
Id1,
Id2,
[dateTime],
ROW_NUMBER() OVER (PARTITION BY Id2 ORDER BY [dateTime] DESC) As RN
FROM
table1
)
INSERT INTO table2
(
Id1,
Id2,
[dateTime]
)
SELECT
Id1,
Id2,
[dateTime]
FROM
cte
WHERE
RN = 1
;
ROW_NUMBER (Transact-SQL) - SQL Server | Microsoft Docs[
^]